var eddieChatWindow
var eddieInput
var eddieButton

function eddieGuestTalk() {
	eddieChatWindow.innerHTML += eddieInput.value + "\n"
	eddieChatWindow.scrollTop = eddieChatWindow.scrollHeight
	eddieInput.value = ""
}

function initChat() {
	document.getElementById("eddie-chat").innerHTML = `
	<textarea id='eddie-chatwindow' readonly></textarea>
	<div id='eddie-inputbar'>
		<input type='text' id='eddie-textfield' onblur='eddieGuestTalk()'>
		<input type='submit' value='Submit' id='eddie-submitbutton' onclick='eddieGuestTalk()'>
	</div>
`

	eddieChatWindow = document.getElementById("eddie-chatwindow")
	eddieInput = document.getElementById("eddie-textfield")
	eddieButton = document.getElementById("eddie-submitbutton")

	eddieInput.addEventListener("keyup", function(event) {
		if (event.keyCode === 13) {
			eddieGuestTalk()
		}
	})
}

